package com.wtcrazy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wtcrazy.entity.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper//用来操作数据库
public interface AdminMapper extends BaseMapper<Admin> {
    Admin login(@Param("admin") Admin admin);

    List<User> getAllUsers();

    void deleteUser(@Param("id") String id);//@Param为SQL语句中参数赋值而服务的,作用就是给参数命名,对应SQL的#{id}

    @Select("select * from user where username like #{username} limit #{pageNum}, #{pageSize}")
    List<User> selectUserPage(Integer pageNum, Integer pageSize, String username);

    @Select("select count(*) from user where username like concat('%', #{username}, '%') ")
    Integer selectUserTotal(String username);


    List<Post> selectPostPage(Integer pageNum, Integer pageSize, String title, String content);

    @Select("select count(*) from posts where title like concat('%', #{title} ,'%') or content like concat('%', #{content} ,'%')")
    Integer selectPostTotal(String title, String content);

    List<Object> getView();

    List<Comment> getcomment();

    List<Record> getRecord();

    @Select("select count(*) from comment where content like concat('%', #{content}, '%')")
    Integer selectCommentTotal(String content);


    List<Comment> selectCommentPage(Integer pageNum, Integer pageSize, String content);

    List<Order> selectOrderPage(String id, Integer pageNum, Integer pageSize);

    @Select("select count(*) from `order` where id like concat('%', #{id} ,'%') ")
    Integer selectOrderTotal(String id);

}
